using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Xml;
using System.Web;
using System.Web.Services;
using Config = Dimok.Config;
using Dimok.Data;
using Dimok.Data.Database;
using Dimok.Exceptions;
using Dimok.Images;
using V = Dimok.Verification;
using Dimok.Aspx.Manager.Lib;
using Data;

namespace Dimok.Aspx.Manager.Verification{
	/// <summary>
	/// Summary description for Tree_WS.
	/// </summary>
	public class Tree_WS : WS,Dimok.Verification.IWS{
		public Tree_WS() {
			//CODEGEN: This call is required by the ASP.NET Web Services Designer
			InitializeComponent();
		}

		#region Component Designer generated code
		
		//Required by the Web Services Designer 
		private IContainer components = null;
				
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent() {
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing ) {
			if(disposing && components != null) {
				components.Dispose();
			}
			base.Dispose(disposing);		
		}
		
		#endregion

		[WebMethod]
		public void AddItemInfo(XmlElement xmlRS){
			try{	V.WS.AddItemInfo(xmlRS,uox.Verification.StatusID);
			}catch(Exception exc){throw new ClientException(exc);}
		}
		private void UpdateItemsInfo(int ID,string label,string description,string descToBroker,string pageID,string imageID){
			try{
				string update = 
					"UPDATE t_Verification SET "+
					"Lable=@Label,Description=@Description,DescToBroker=@DescToBroker,PageID=@PageID,ImageTypeID=@ImageID "+
					"WHERE ID="+ID;
				SQL.ExecuteNonQuery(update,label,description,descToBroker,pageID,imageID);
			}catch(Exception exc){throw new ClientException(exc);}
		}
		[WebMethod]
		public string UpdateVerInfo(XmlElement xmlRS ){
			try{	return V.WS.UpdateVerInfo(xmlRS);
			}catch(Exception exc){throw new ClientException(exc);}
		}
		[WebMethod]
		public void LevelItemUp(int ID){
			try{	V.WS.LevelItemUp(ID);
			}catch(Exception exc){throw new ClientException(exc);}
		}
		[WebMethod]
		public void CopyItem(int ID,int parentID,int afterID,int menuID,bool move){
			try{	V.WS.CopyItem(ID,parentID,afterID,menuID,move);
			}catch(Exception exc){throw new ClientException(exc);}
		}
		[WebMethod]
		public void DeleteVerItem(int ID){
			try{	V.WS.DeleteVerItem(ID);
			}catch(Exception exc){throw new ClientException(exc);}
		}
		private void UpdateItemInfo(int ID,string fieldName,object fieldValue ){
			try{
				SQL.UpdateField(new UOX().db,"SELECT * FROM t_Verification WHERE ID="+ID,fieldName,fieldValue);
			}catch(Exception exc){throw new ClientException(exc);}
		}
		[WebMethod]
		public string UpdateChecked(int ID,bool isChecked){
			try{ return V.WS.UpdateChecked(ID,isChecked);
			}catch(Exception exc){throw new ClientException(exc);}
		}
		//***** Info *****
		[WebMethod]
		public string VerificationItem(int verID){
			try{
				return V.WS.VerificationItem(verID);
			}catch(Exception exc){throw new ClientException(exc);}
		}
		[WebMethod]
		public string VerificationItems(){
			try{
				return V.WS.VerificationItems();
			}catch(Exception exc){throw new ClientException(exc);}
		}
		[WebMethod]
		public string VerItemHist(int verID){
			try{
				UOX uox = new UOX();
				return SQL.XmlInnerText(uox.db,"SELECT * FROM dbo.fverTree_Hist("+uox.applID+","+verID+")");
			}catch(Exception exc){throw new ClientException(exc);}
		}
		[WebMethod]
		public string VerificationTree(int msg){
			try{
				return V.WS.VerificationTreeXML(msg);
			}catch(Exception exc){throw new ClientException(exc);}
		}

		//***** Add-Ons *****
		[WebMethod]
		public void FaxAppraisalRequest(string html){
			try{
				UOX uox = new UOX();
				Dimok.Fax.HTML(html,"Dimok","Dimon","3057751657",Config.application.FaxEMail,Config.application.MailServer);
			}catch(Exception exc){throw new ClientException(exc);}
		}
	}
}
